package com.nl.controller.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.nl.controller.common.model.Response;
import com.nl.controller.common.util.ResponseUtil;
import com.nl.controller.web.bean.SmsCitySignInfo;
import com.nl.controller.web.service.SmsCitySignService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
@RequestMapping("citySign")
public class SmsCitySignController {
	@Autowired
    private SmsCitySignService smsCitySignService ;
	@ApiOperation(value = "查询地市标识", notes = "分页查询地市标识")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "limit", value = "每页数量", required = true, dataType = "String"),
            @ApiImplicitParam(name = "cityId", value = "地市编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "signId", value = "标识编码", required = true, dataType = "String")
    })
    @PostMapping("find")
    public Response findCitySign(
            @RequestParam(value = "page", required = true) int page,
            @RequestParam(value = "limit", required = true) int limit,
            @RequestParam(value = "cityId", required = false) String cityId,
            @RequestParam(value = "signId", required = false) String signId,
            @RequestParam Map<String, Object> paramMap
    ) {
        PageInfo<SmsCitySignInfo> pageInfo = smsCitySignService.find(page, limit, cityId, signId);
        log.info(" 查询地市标识：{}", paramMap.toString());
        log.debug("查询地市标识返回参数：{}", pageInfo.getList().toString());
        return ResponseUtil.sucess(pageInfo.getList(), pageInfo.getTotal());

    }
	
	@PostMapping("modify")
	    public int modifyCitySign(
	    		@RequestParam(value = "cityId", required = false) String cityId,
	            @RequestParam(value = "signId", required = false) String signId,
	            @RequestParam Map<String, Object> paramMap
	    ) {
			int result = smsCitySignService.modifyCitySign(cityId,signId);
	        log.info(" 修改地市标识：{}", paramMap.toString());
	        log.debug("修改地市标识返回参数：{}", result);
	        return result;
	    }
	
	@PostMapping("findHis")
    public SmsCitySignInfo findCitySignHis(
            @RequestParam(value = "seqId", required = true) String seqId,
            @RequestParam Map<String, Object> paramMap
    ) {
        SmsCitySignInfo smsCitySignInfo = smsCitySignService.findCitySignHis(seqId);
        log.info(" 查询历史地市标识：{}", paramMap.toString());
        log.debug("查询历史地市标识返回参数：{}", smsCitySignInfo.toString());
        return smsCitySignInfo;

    }
}
